package A009list_set;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class B004_ArrayList线程安全例子CopyOnWriteArrayList {

    public static void main(String[] args) {
        List<String> list = new CopyOnWriteArrayList<>();

        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                list.add(String.valueOf(System.currentTimeMillis()));
                System.out.println(list);
            }, String.valueOf(i + 1)).start();
        }
    }
}
